package com.eternal.webSocke.encoder;/**
 * @Title: ServerEncoder
 * @ProjectName notest
 * @Description: TODO
 * @author Eternal
 * @date 2018/12/23 21:38
 */

import com.alibaba.fastjson.JSON;
import com.eternal.webSocke.vo.MessageVo;

import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;

/**
 * @Class ServerEncoder
 * @Description: TODO
 * @Author Eternal
 * @Version
 * @date 2018/12/23 21:38
 */
public class ServerEncoder implements Encoder.Text<MessageVo> {
    @Override
    public void destroy() {
        // TODO Auto-generated method stub

    }

    @Override
    public void init(EndpointConfig arg0) {
        // TODO Auto-generated method stub

    }

    @Override
    public String encode(MessageVo messageVo) throws EncodeException {
    return JSON.toJSONString(messageVo);
        /*try {
            return Java2Json.JavaToJson(messagepojo, false);
        } catch (MapperException e) {
            e.printStackTrace();
            return null;
        }*/
    }

}
